<?php
	class DatabakControl extends CommonControl{

		function index(){
			$config = include "./config/backup.php";
			$this->assign('config',$config);
			$this->display();
		}

		function huanyuan(){
			$file=dir::tree('./backup');
			$this->assign('file',$file);
			$this->display();
		}

		function bakre(){
			$dir="./backup/".$_GET['dir'];
           	backup::recovery(array(
               "dir" => $dir,
               "url" => "__success",
               "step_time"=>0,
               )
           );
		}

		function __success(){
        	$this->success("还原成功",'index');
    	}

		function editbak(){		
			$data=$_POST;
			$file=var_export($data,true);
			$str="<?php\nif(!defined('PATH_HD'))exit;\n return ";
        	$str.=$file.";\n?>";
        	file_put_contents("./config/backup.php",$str);
        	go("runbak");
        }

        function runbak(){
        	$config = include "./config/backup.php";
			Backup::backup(
				array(
		            "url" => "index",
		            "dir" => "./backup/" .NOW,
		            "step_time"=>$config['backup_step_time'],
		            "row"=>$config['backup_row']
        		)
        	);
		}	
	}
?>